package xworker.gluon.attach.accelerometer;

import com.gluonhq.attach.accelerometer.AccelerometerService;
import com.gluonhq.attach.accelerometer.Parameters;
import org.xmeta.ActionContext;
import org.xmeta.Thing;

public class AccelerometerServiceActions {
    public static void start(ActionContext actionContext){
        Thing self = actionContext.getObject("self");

        AccelerometerService accelerometerService = self.doAction("getAccelerometerService", actionContext);
        Double frequency = self.doAction("getFrequency", actionContext);
        Boolean isFilteringGravity = self.doAction("isIsFilteringGravity", actionContext);

        Parameters parameters = new Parameters(frequency, isFilteringGravity);
        accelerometerService.start(parameters);

    }

    public static void stop(ActionContext actionContext){
        Thing self = actionContext.getObject("self");

        AccelerometerService accelerometerService = self.doAction("getAccelerometerService", actionContext);
        accelerometerService.stop();

    }
}
